// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
//导入element
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
//导入axios
import axios from 'axios'
import VueAxios from 'vue-axios'
import Vuex from 'vuex'

//js
import './assets/js/cookies'

//css
import './assets/css/common.css'
import './assets/css/text.css'

//导入路由配置目录
import  router from './router'

Vue.config.productionTip = false

//显式的使用
Vue.use(ElementUI);
Vue.use(VueAxios, axios);
Vue.use(Vuex);

axios.defaults.baseURL = 'http://www.embeddedvr.net';  //product
// axios.defaults.baseURL = 'http://localhost:8085';  //dev
//否则无法使用session(目前猜测是代理的缘故)
axios.defaults.withCredentials=true

//配置vuex

const store = new Vuex.Store({
  state: {
    user:{
      isLogin: 0,
      userId:'',
      userNickname: '',
      userIsTeacher: 0
    },
    hostAccount:{
      hostAccountId: '',
      hostAccountIp: '',
      hostUsername: '',
      hostPassword: ''
    }
  },
  mutations: {
    changeLoginState (state) {
      state.user.isLogin = 1- state.user.isLogin;
    },
    setUserNickname (state,playload) {
      state.user.userNickname = playload;
    },
    setUserId(state,playload){
      state.user.userId = playload;
    },
    setTeacher(state,playload){
      state.user.userIsTeacher = playload;
    },
    setHostAccount(state,hostAccount){
      state.hostAccount = hostAccount;
    },
  }
})

/* eslint-disable no-new */
/*将Vue挂载到window下可以方便在指令台中查找*/
window.vue = new Vue({
  el: '#app',
  //配置路由
  router,
  //配置vuex
  store,
  components: { App },
  template: '<App/>',
  render: h => h(App),
})
